*-------------------------------------------------------------------------------
// University of Basel / University of Konstanz
//  
// Electoral Vulnerability and Women MPs' Estimation of Voters' Preferences on
// Women's Issues
//
// Daniel Höhmann/Stefanie Bailer/Christian Breunig 				January 2026
*-------------------------------------------------------------------------------

version 18
set more off
clear
macro drop _all


use "Hoehmann_et_al_Replication", clear




/* -------------- Variables ----------------------------------------------------

sex					Biological sex of MP
age					Age of politician
seniority			Tenure of politician (in years)
com_1				Committee Membership
Q16					MP's perception of party electorate
ele_agr_cal			Agreement with policy (all party voters)
ele_agr_cal_female	Agreement with policy (women party voters)
Q6_5				Representation of special group
Q7					Follow own convictions
Q17_2				Source public opinion: Citizens
Q22_23				Perception re-election probabilty
CMP_RiLE			MARPOR Left-Right score
V3					MP ID
V5					MP on regional or federal level
V2					Country
SID					ID for policy statements

----- Policy Statements (SID) ----- 
ch_A4				Baby hatch
ch_A5				Sexual harassment
ch_B4				Adoption rights for same-sex couples
ch_B8				Separate tax assesment for wedded people

de_A7				Women should be privileged on the labor market
de_B6				Right to full-time child care until the end of elementary school
------------------------------------------------------------------------------*/   


*-------------------------------------------------------------------------------
// Data Management												        	   |
*-------------------------------------------------------------------------------


* ----- Dependent variable: Calculate Prediction Error ----- *

mvdecode Q16, mv(-99)

gen pred_error_electorate = abs(Q16 - ele_agr_cal)
gen accuracy_electorate = 100-pred_error_electorate

* Public opinion of women

gen pred_error_electorate_female = abs(Q16 - ele_agr_cal_female)
gen accuracy_electorate_female = 100-pred_error_electorate_female


* ----- Generate independent variables ----- *

gen com_soc = 0							// Member of women's committee or committe social affairs and health
replace com_soc = 1 if com_1 == "NA04" | com_1 == "GE03" | com_1 == "BE06" | com_1 == "AfFamSeFraJug" 

gen kanton = .							// MP in Kanton
replace kanton = 1 if V5 == 1 
replace kanton = 0 if V5 == 2 | V2 == 5

gen swiss = .							// Swiss MP
replace swiss = 1 if V2 == 3
replace swiss = 0 if V2 == 5

mvdecode Q6_5 Q7 Q17_2 Q22_23, mv(-99)
 
rename (Q6_5 Q7 Q17_2 Q22_23) (rep_spec_gr own_conv pub_opi_citizens safety_reelection)

recode safety_reelection (1=4 "Very high") (2=3 "High") (3=2 "Medium") (4=1 "Low") (5=0 "Very low"), gen(electoral_vulnerability)
label var electoral_vulnerability "Electoral Vulnerability"

tab SID, gen(SID_)

drop if pred_error_electorate == . | sex == . | electoral_vulnerability == . | age == . | seniority == . | rep_spec_gr == . | own_conv == . | pub_opi_citizens == . | com_soc == . | swiss == . | kanton == . | CMP_RiLE == .



*-------------------------------------------------------------------------------
// Replication of main models										       	   |
*-------------------------------------------------------------------------------

* ----- Table 1 ----- *

// Model 1
reg accuracy_electorate sex electoral_vulnerability age seniority rep_spec_gr own_conv pub_opi_citizens com_soc swiss kanton CMP_RiLE if SID=="ch_A4" | SID=="ch_A5" |SID=="ch_B4" | SID=="ch_B8" | SID=="de_A7" | SID=="de_B6", vce(cluster V3) 

// Model 2
reg accuracy_electorate_female sex electoral_vulnerability age seniority rep_spec_gr own_conv pub_opi_citizens com_soc swiss kanton CMP_RiLE if SID=="ch_A4" | SID=="ch_A5" |SID=="ch_B4" | SID=="ch_B8" | SID=="de_A7" | SID=="de_B6", vce(cluster V3) 

// Model 3
reg accuracy_electorate i.sex##c.electoral_vulnerability age seniority rep_spec_gr own_conv pub_opi_citizens com_soc swiss kanton CMP_RiLE if SID=="ch_A4" | SID=="ch_A5" | SID=="ch_B4" | SID=="ch_B8" | SID=="de_A7" | SID=="de_B6", vce(cluster V3)

// Model 4
reg accuracy_electorate_female i.sex##c.electoral_vulnerability age seniority rep_spec_gr own_conv pub_opi_citizens com_soc swiss kanton CMP_RiLE if SID=="ch_A4" | SID=="ch_A5" | SID=="ch_B4" | SID=="ch_B8" | SID=="de_A7" | SID=="de_B6", vce(cluster V3)


* ----- Marginal effects plot (Figure 2) ----- *
reg accuracy_electorate i.sex##c.electoral_vulnerability age seniority rep_spec_gr own_conv pub_opi_citizens com_soc swiss kanton CMP_RiLE if SID=="ch_A4" | SID=="ch_A5" | SID=="ch_B4" | SID=="ch_B8" | SID=="de_A7" | SID=="de_B6", vce(cluster V3)
margins sex, at(electoral_vulnerability=(0(1)4))
margins, dydx(sex) at(electoral_vulnerability=(0(1)4)) 
marginsplot


* ----- Placebo anlysis (Table 2) ----- *

// Model 5
#delimit ;
reg accuracy_electorate sex electoral_vulnerability age seniority rep_spec_gr own_conv pub_opi_citizens com_soc swiss kanton CMP_RiLE 
		if SID=="ch_A1" | SID=="ch_A2" | SID=="ch_A3" |SID=="ch_A6" | SID=="ch_A7" | SID=="ch_A8" |SID=="ch_A9" 
		 | SID=="ch_B1" | SID=="ch_B2" | SID=="ch_B3" |SID=="ch_B4" | SID=="ch_B5" | SID=="ch_B6" | SID=="ch_B7" |SID=="ch_B9"
		 | SID=="de_B1" | SID=="de_B2" | SID=="de_B3" |SID=="de_B5" | SID=="de_B7" |SID=="de_B8" 
		 | SID=="de_A1" | SID=="de_A2" | SID=="de_A3" |SID=="de_A4" | SID=="de_A5" | SID=="de_A6" |SID=="de_A8"
		, vce(cluster V3) 
;
#delimit cr

// Model 6
#delimit ;
reg accuracy_electorate i.sex##c.electoral_vulnerability age seniority rep_spec_gr own_conv pub_opi_citizens com_soc swiss kanton CMP_RiLE 
		if SID=="ch_A1" | SID=="ch_A2" | SID=="ch_A3" |SID=="ch_A6" | SID=="ch_A7" | SID=="ch_A8" |SID=="ch_A9" 
		 | SID=="ch_B1" | SID=="ch_B2" | SID=="ch_B3" |SID=="ch_B4" | SID=="ch_B5" | SID=="ch_B6" | SID=="ch_B7" |SID=="ch_B9"
		 | SID=="de_B1" | SID=="de_B2" | SID=="de_B3" |SID=="de_B5" | SID=="de_B7" |SID=="de_B8" 
		 | SID=="de_A1" | SID=="de_A2" | SID=="de_A3" |SID=="de_A4" | SID=="de_A5" | SID=="de_A6" |SID=="de_A8"
		, vce(cluster V3) 
;
#delimit cr

// Model 7
#delimit ;
reg accuracy_electorate_female sex electoral_vulnerability age seniority rep_spec_gr own_conv pub_opi_citizens com_soc swiss kanton CMP_RiLE 
		if SID=="ch_A1" | SID=="ch_A2" | SID=="ch_A3" |SID=="ch_A6" | SID=="ch_A7" | SID=="ch_A8" |SID=="ch_A9" 
		 | SID=="ch_B1" | SID=="ch_B2" | SID=="ch_B3" |SID=="ch_B4" | SID=="ch_B5" | SID=="ch_B6" | SID=="ch_B7" |SID=="ch_B9"
		 | SID=="de_B1" | SID=="de_B2" | SID=="de_B3" |SID=="de_B5" | SID=="de_B7" |SID=="de_B8" 
		 | SID=="de_A1" | SID=="de_A2" | SID=="de_A3" |SID=="de_A4" | SID=="de_A5" | SID=="de_A6" |SID=="de_A8"
		, vce(cluster V3) 
;
#delimit cr

// Model 8
#delimit ;
reg accuracy_electorate_female i.sex##c.electoral_vulnerability age seniority rep_spec_gr own_conv pub_opi_citizens com_soc swiss kanton CMP_RiLE 
		if SID=="ch_A1" | SID=="ch_A2" | SID=="ch_A3" |SID=="ch_A6" | SID=="ch_A7" | SID=="ch_A8" |SID=="ch_A9" 
		 | SID=="ch_B1" | SID=="ch_B2" | SID=="ch_B3" |SID=="ch_B4" | SID=="ch_B5" | SID=="ch_B6" | SID=="ch_B7" |SID=="ch_B9"
		 | SID=="de_B1" | SID=="de_B2" | SID=="de_B3" |SID=="de_B5" | SID=="de_B7" |SID=="de_B8" 
		 | SID=="de_A1" | SID=="de_A2" | SID=="de_A3" |SID=="de_A4" | SID=="de_A5" | SID=="de_A6" |SID=="de_A8"
		, vce(cluster V3) 
;
#delimit cr


*-------------------------------------------------------------------------------
// Replication of robustness tests									       	   |
*-------------------------------------------------------------------------------

* ----- Issue fixed-effects ----- *

// Model A1
reg accuracy_electorate i.sex##c.electoral_vulnerability age seniority rep_spec_gr own_conv pub_opi_citizens com_soc swiss kanton CMP_RiLE SID_4 SID_5 SID_13 SID_17 SID_25 SID_32 if SID=="ch_A4" | SID=="ch_A5" |SID=="ch_B4" |SID=="ch_B8" | SID=="de_A7" | SID=="de_B6", vce(cluster V3)

// Model A2
reg accuracy_electorate_female i.sex##c.electoral_vulnerability age seniority rep_spec_gr own_conv pub_opi_citizens com_soc swiss kanton CMP_RiLE SID_4 SID_5 SID_13 SID_17 SID_25 SID_32 if SID=="ch_A4" | SID=="ch_A5" |SID=="ch_B4" |SID=="ch_B8" | SID=="de_A7" | SID=="de_B6", vce(cluster V3)


* ----- Post-treatment bias: Modells without control for women's committee ----- *

// Model A3
reg accuracy_electorate i.sex##c.electoral_vulnerability age seniority rep_spec_gr own_conv pub_opi_citizens swiss kanton CMP_RiLE if SID=="ch_A4" | SID=="ch_A5" | SID=="ch_B4" | SID=="ch_B8" | SID=="de_A7" | SID=="de_B6", vce(cluster V3)

// Model A4
reg accuracy_electorate_female i.sex##c.electoral_vulnerability age seniority rep_spec_gr own_conv pub_opi_citizens swiss kanton CMP_RiLE if SID=="ch_A4" | SID=="ch_A5" | SID=="ch_B4" | SID=="ch_B8" | SID=="de_A7" | SID=="de_B6", vce(cluster V3)


* ----- Model without policy statement for same-sex adoption ----- * 

// Model A5
reg accuracy_electorate sex c.electoral_vulnerability age seniority rep_spec_gr own_conv pub_opi_citizens com_soc swiss kanton CMP_RiLE if SID=="ch_A4" | SID=="ch_A5" | SID=="ch_B8" | SID=="de_A7" | SID=="de_B6", vce(cluster V3)

// Model A6
reg accuracy_electorate_female sex c.electoral_vulnerability age seniority rep_spec_gr own_conv pub_opi_citizens com_soc swiss kanton CMP_RiLE if SID=="ch_A4" | SID=="ch_A5" | SID=="ch_B8" | SID=="de_A7" | SID=="de_B6", vce(cluster V3)

// Model A7
reg accuracy_electorate i.sex##c.electoral_vulnerability age seniority rep_spec_gr own_conv pub_opi_citizens com_soc swiss kanton CMP_RiLE if SID=="ch_A4" | SID=="ch_A5" | SID=="ch_B8" | SID=="de_A7" | SID=="de_B6", vce(cluster V3)

// Model A8
reg accuracy_electorate_female i.sex##c.electoral_vulnerability age seniority rep_spec_gr own_conv pub_opi_citizens com_soc swiss kanton CMP_RiLE if SID=="ch_A4" | SID=="ch_A5" | SID=="ch_B8" | SID=="de_A7" | SID=="de_B6", vce(cluster V3)


* ----- Objective measure for electoral vulnerability ----- * 

keep if V2 == 3 // (Data only available for Switzerland)

// Create variable for inter-party vulnerability
recode order (-99 = .), gen(order_election)
recode dm_party_seat (-99 = .), gen(party_seats_district)
gen elec_vul_objective_inter = (order_election/party_seats_district)
drop if elec_vul_objective_inter > 1

// Model A9
reg accuracy_electorate sex elec_vul_objective_inter age seniority rep_spec_gr own_conv pub_opi_citizens com_soc kanton CMP_RiLE if SID=="ch_A4" | SID=="ch_A5" |SID=="ch_B4" | SID=="ch_B8" | SID=="de_A7" | SID=="de_B6", vce(cluster V3) 

// Model A10
reg accuracy_electorate_female sex elec_vul_objective_inter age seniority rep_spec_gr own_conv pub_opi_citizens com_soc kanton CMP_RiLE if SID=="ch_A4" | SID=="ch_A5" |SID=="ch_B4" | SID=="ch_B8" | SID=="de_A7" | SID=="de_B6", vce(cluster V3) 

// Model A11
reg accuracy_electorate i.sex##c.elec_vul_objective_inter age seniority rep_spec_gr own_conv pub_opi_citizens com_soc kanton CMP_RiLE if SID=="ch_A4" | SID=="ch_A5" | SID=="ch_B4" | SID=="ch_B8" | SID=="de_A7" | SID=="de_B6", vce(cluster V3)

// Model A12
reg accuracy_electorate_female i.sex##c.elec_vul_objective_inter age seniority rep_spec_gr own_conv pub_opi_citizens com_soc kanton CMP_RiLE if SID=="ch_A4" | SID=="ch_A5" | SID=="ch_B4" | SID=="ch_B8" | SID=="de_A7" | SID=="de_B6", vce(cluster V3)


* ----- Marginal effects plot ----- *
reg accuracy_electorate i.sex##c.elec_vul_objective_inter age seniority rep_spec_gr own_conv pub_opi_citizens com_soc kanton CMP_RiLE if SID=="ch_A4" | SID=="ch_A5" | SID=="ch_B4" | SID=="ch_B8" | SID=="de_A7" | SID=="de_B6", vce(cluster V3)
margins, dydx(sex) at(elec_vul_objective_inter=(0(0.1)1)) 
marginsplot



*-------------------------------------------------------------------------------
// Replication of descriptive analysis								       	   |
*-------------------------------------------------------------------------------

* ----- Figure 1 ----- *

keep if SID=="ch_A4" | SID=="ch_A5" |SID=="ch_B4" | SID=="ch_B8" | SID=="de_A7" | SID=="de_B6"

twoway (histogram accuracy_electorate if sex==1, start(13.25) width(4.58) percent color(black%30)) ///        
       (histogram accuracy_electorate if sex==0, start(13.25) width(4.58) percent ///   
       fcolor(none) lcolor(black)), legend(order(1 "Female MPs" 2 "Male MPs" ))
	   
twoway (histogram accuracy_electorate_female if sex==1, start(17.089005) width(4.3590522) percent color(black%30)) ///        
       (histogram accuracy_electorate_female if sex==0, start(17.089005) width(4.3590522) percent ///   
       fcolor(none) lcolor(black)), legend(order(1 "Female MPs" 2 "Male MPs" ))


